//
//  LzwBroadcastCell.m
//  CoJellyCartoon
//
//  Created by 刘志武 on 16/4/5.
//  Copyright © 2016年 CJG. All rights reserved.
//

#import "LzwBroadcastCell.h"

@interface LzwBroadcastCell ()

@property (nonatomic, strong) UIImageView *myImageView;
@property (nonatomic, strong) UILabel *lableTitle;
@property (nonatomic, strong) UILabel *lableTime;

@end


@implementation LzwBroadcastCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self getBrocastCell];
    }
    
    return self;
}

-(void)getBrocastCell{
    
    
    self.myImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:self.myImageView];
    
    self.lableTitle = [[UILabel alloc]init];
    self.lableTitle.textAlignment = 1;
    [self.contentView addSubview:self.lableTitle];
    
    
    self.lableTime = [[UILabel alloc]init];
    self.lableTime.textColor = [UIColor lightGrayColor];
    self.lableTime.numberOfLines = 0;
    self.lableTime.textAlignment = 1;
    self.lableTime.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.lableTime];
    
    [self.myImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.left.equalTo(self.contentView).offset(10);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(130);
        
    }];
    
    [self.lableTitle mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.contentView).offset(20);
        make.left.equalTo(self.myImageView.mas_right).offset(10);
        make.width.mas_equalTo(200);
        make.height.mas_equalTo(20);
        
        
    }];
   
    [self.lableTime mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.lableTitle.mas_bottom).offset(40);
        make.left.equalTo(self.myImageView.mas_right).offset(10);
        make.width.equalTo(self.lableTitle);
        make.height.mas_equalTo(40);
        
        
    }];
    
    
}

- (void)setModelB:(LzwBroadcastModle *)modelB{
    
    _modelB = modelB;

    NSURL *url = [NSURL URLWithString:_modelB.cover];
    
    [self.myImageView sd_setImageWithURL:url placeholderImage:nil];
    
    NSString *str = @"放送时间:\n";
    NSString *str1 = _modelB.lastupdate_at;
    
    self.lableTime.text = [str stringByAppendingString:str1];
    self.lableTitle.text = _modelB.title;
    
}


@end
